﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using Csla;
using Csla.Core;
using OpenExpressApp.MetaModel;

namespace OpenExpressApp
{
    public class FilteredListAdapter<T> : LinqBindingList<T>, IUnderlyModelList
    {
        private LinqBindingList<T> _filteredList;
        private IUnderlyModelList _sourceList;

        public FilteredListAdapter(LinqBindingList<T> filteredList, IUnderlyModelList sourceList)
            : base(sourceList as IList<T>)
        {
            if (filteredList == null) throw new ArgumentNullException("filteredList");
            if (sourceList == null) throw new ArgumentNullException("sourceList");

            this._filteredList = filteredList;
            this._sourceList = sourceList;
        }

        #region IUnderlyModelList Members

        public IList GetDisplayModels(IQueryObject criteria)
        {
            return this._sourceList.GetDisplayModels(criteria);
        }

        public IList GetDisplayModels(BusinessBase parent)
        {
            return this._sourceList.GetDisplayModels(parent);
        }

        #endregion
    }
}
